How to... Write and use scripts
MyAlbum has an integrated script tool that enables you to write scripts (in VBScript, javascript, Perl,...)
that will extend the possibilities of MyAlbum. With scripts you can for instance:
- Perform repetitive or often used sequences of actions,
- Define new commands by attaching a script to a keyboard shortcut,
- Access external data stored in a database or a spreadsheet file,
- Export an album to a Microsoft PowerPoint presentation,
- Build custom web pages,
- ....
Important notice: This functionality will work only if ActiveX Scripting is installed
and enabled on your computer. This should be the case if you have Microsoft Internet Explorer 4.0
installed or are running Microsoft Windows 98.
Useful information
- See the Scriptable Objects chapter for the description of the
objects, properties and methods that can be used in a script.
- For a description of the script language, please refer to the Microsoft Web site (
http://msdn.microsoft.com/scripting/VBScript).
On the same site, you will find a script debugger that can be useful for tracking errors in yours programs.
- Most scripts can be run outside MyAlbum or converted to other macro languages. To do this, you will have to define the app object.
For instance in VB or VBA:
dim app as Object
set app = CreateObject("MyAlbum.Application")
- You are not limited to the VBScript or the JScript languages, in fact you can use any script
language compatible with the ActiveX Scripting like Perl, Python, Haskell...
See Installing a script language for more details.
Using scripts with the MyAlbum viewer
The MyAlbum viewer (MyAlbumViewer.exe and all-in-one albums built using the viewer) is able to run scripts too but with some limitations:
- Only VBScript and Jscript can be used,
- Do not use the MyAlbum constants (such as SS_VIEWPIC or TYPE_JPEG) but use their real value (1 for SS_VIEWPIC and 2 for TYPE_JPEG). If the album is played on a computer where MyAlbum has not been installed, these constants will not be defined and the script will fail to run.
- The viewer supports a subset of the MyAlbum object model. All functions used to modify or create albums, files and pictures are not supported (album.Save, album.AddPicture, picture.ConvertAndResize, picture.xmlEncode,...).
Writing your first scripts
I know nothing of these VBScript, javascript, Perl,...!
To write a script you will need some basic knowledge of computer programming. The Microsoft site
(see above) provides lots of information on VBScript and JScript.
What you will need is:
- Ability to write (small ands simple) programs in one of the languages supported by MyAlbum,
- Understanding of the MyAlbum object model.
Writing your first script may seem a complex and intimidating task at first. To help you, you will find
some demo scripts in the MyAlbum folder. By using them and studying their code you will soon be able
to modify and adapt them to your needs as it's always easier to start from an existing working code than
having to write it from scratch.
Soon, you will master the Art of Script Writing and discover the true power of MyAlbum!
You will find on the MyAlbum web site
a large selection of ready-to-use scripts. Download them, use them, study them, modify them!
I'm an expert in VBScript, javascript, Perl,...!
Then, just pick, in the languages supported by MyAlbum, the one you prefer, study
the MyAlbum object model and you will soon be
able to write your own MyAlbum scripts.
You have written some useful and/or interesting scripts ?
Send them to support@myalbumpro.com so
they can be made available to the other MyAlbum users.
But I don't want to write scripts!
Fortunately, most of the scripts available on the MyAlbum web site
do not require at all that you understand each line of code in order to use them!
Each starts with a header comment that contains a description of the script, its purpose
and how to use it.